<style lang="less">

  .company-list {
    height: 100%;
    background-color: #fff;
    .company-list-content {
      margin-left: 74px;
      padding-top: 166px;
      .company-list-title {
        padding-bottom: 20px;
        color: rgba(49, 49, 49, 1);
        font-size: 36px;
        text-align: justify;
      }
      ul {
        margin-top: 50px;
        margin-bottom: 24px;
        -webkit-overflow-scrolling: touch;
        li {
          margin-right: 76px;
          height: 98px;
          padding-top: 38px;
          //line-height: 74px;
          .iconfont-li {
            font-size: 18px;
            color: #cfcfcf;
            margin-right: 22px;
          }
          color: rgba(121, 121, 121, 1);
          span {
            font-size: 32px;
            color: rgba(121, 121, 121, 1);
          }
          img {
            width: 26px;
            height: 26px;
          }
          .check-span {
            margin-left: 23px;
          }
          .un-check-span {
            margin-left: 23px;
          }
          border-bottom: 1px solid #F1F1F1;
        }
        li:last-child {
          border: 0
        }
      }
      .un-check {
        color: #313131;
      }
    }
  }

</style>

<template>
  <div class="company-list">
    <header-bar
      center-color="#3D3C3C"
      left-color="#536DFE"
      bg-color="#ffffff"
    >
      <span slot="title">忘记密码</span>
    </header-bar>

    <div>
      <div class="company-list-content">
        <div class="company-list-title">
          请选择企业，重置密码
        </div>
        <div>
          <ul v-show="list">
            <!-- <template v-for="(item,index) of list" > -->
            <li
              v-for="(item,index) of list"
              :key="index"
              @tap="selCompany(item,index)"
            >
              <!-- <img
                v-show="selIndex==index"
                src="../../assets/JE-Check-the-01.png"
                class="check-img"
              >

              <img
                v-show="selIndex!=index"
                src="../../assets/JE-circle-01.png"
                class="un-check-img"
              > -->
              <span
                :class="[selIndex==index?'check-span':'un-check-span']"
              >{{ item.DEPTNAME | ellipsisStr(11) }}</span>
            </li>
            <!-- </template> -->
          </ul>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import { fetchSearchUserCode } from '../../actions/login';
import { openWindow } from '@/helper';

export default {
  name: 'CompanyList',
  components: {},
  data() {
    return {
      list: [],
      selIndex: '-',
      params: {},
    };
  },
  created() {

  },
  mounted() {
    const currentWeb = plus.webview.currentWebview();
    this.params = currentWeb;
    this.getList();
  },
  methods: {
    async selCompany(item, index) {
      this.selIndex = index;
      openWindow({
        url: './pages_setNewPwd_index.html',
        id: '__setNewPwdView',
        title: '重置密码',
        extras: {
          phone: this.params.phone,
          validateCode: this.params.validateCode,
          deptId: item.DEPTID,
        },
      });
      /* this.$router.push({
          name: 'setNewPwd',
          params: {
            phone: this.$route.params.phone,
            validateCode: this.$route.params.validateCode,
            deptId: item.DEPTID,
          },
        }); */
    },
    async getList() {
      const userRes = await fetchSearchUserCode({
        userCode: this.params.phone,
      });
      if (userRes.success) {
        this.list = userRes.obj;
      }
    },
  },
};
</script>
